package cn.com.wf.action;

import java.util.ArrayList;
import java.util.List;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.mysql.fabric.xmlrpc.base.Array;

import cn.com.wf.service.TestService;
import cn.com.workflow.util.JsonUtils;


@Controller
public class TestAction {
	@Autowired
	private ProcessEngine processEngine;
	
	@Autowired
	TestService testService;
	
	@RequestMapping(value = "/test", method = RequestMethod.GET)
	public ModelAndView test(){
		 System.out.println("启用流程实例");  
 	    RuntimeService runtimeService = processEngine.getRuntimeService();  
 	    System.out.println("流程已经可以应用");  
 	    ProcessInstance instance = runtimeService  
 	            .startProcessInstanceByKey("1");  
 	    System.out.println("已返回流程实例instance,id为:" + instance.getId());  
 	    System.out.println("获取instance：" + instance);  
 	    System.out.println("获取instance_id：" + instance.getId());  
 	    System.out.println("获取instance_ProcessDefinitionId："  
 	            + instance.getProcessDefinitionId());  
 	    System.out.println("获取instance_ProcessInstanceId："  
 	            + instance.getProcessInstanceId());  
 	    System.out.println("获取instance_BusinessKey：" + instance.getBusinessKey());  
		ModelAndView mav = new ModelAndView();
		mav.addObject("aaa", "~~~");
		mav.setViewName("test");
		return mav;
	}
}
